<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <div class="h_top">
          <div class="bread_title">
            <span>新增设备启停</span>
          </div>
          <div class="add_button">
            <div class="buttonBox">
              <el-button type="primary" icon="el-icon-document-checked" size="mini" @click="save">保存</el-button>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>
    <div>
      <el-row>
        <el-col :span="24">
          <el-form ref="form" :model="data" :inline="true" :rules="formRules">
            <el-row :gutter="10">
              <el-col :span="4">
                <el-form-item prop="coding">
                  <div>编号</div>
                  <el-input v-model="data.coding" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="name">
                  <div>名称</div>
                  <el-input v-model="data.name" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="equipment_id">
                  <div>资产</div>
                  <v-select v-model="data.equipment_id" action="eqList" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="turn">
                  <div>操作</div>
                  <template>
                    <el-radio v-model="data.turn" label="1">启用</el-radio>
                    <el-radio v-model="data.turn" label="2">停用</el-radio>
                  </template>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="date">
                  <div>预计日期</div>
                  <el-date-picker v-model="data.date" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="status">
                  <div>状态</div>
                  <el-select v-model="data.status" size="mini" disabled>
                    <el-option v-for="(item, index) in turnStatus" :key="index" :value="index" :label="item" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="old_value">
                  <div>原值</div>
                  <el-input v-model="data.old_value" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="depreciation">
                  <div>已提折旧</div>
                  <el-input v-model="data.depreciation" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="new_value">
                  <div>净值</div>
                  <el-input v-model="data.new_value" size="mini" />
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item prop="sort">
                  <div>排序</div>
                  <el-input v-model="data.sort" size="mini" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>
          <el-tabs>
            <el-tab-pane label="原因">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="reason" v-model="data.reason" />
                </el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="使用部门意见">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="shiyong" v-model="data.shiyong" />
                </el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="归口管理部门意见">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="guikou" v-model="data.guikou" />
                </el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="资产管理部门意见">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="guanli" v-model="data.guanli" />
                </el-col>
              </el-row>
            </el-tab-pane>
            <el-tab-pane label="描述">
              <el-row :gutter="10">
                <el-col :span="24">
                  <wangeditor id="content" v-model="data.content" />
                </el-col>
              </el-row>
            </el-tab-pane>
          </el-tabs>
        </el-col>
      </el-row>
    </div>
  </div>
</template>
<script>
import API from '@/api/asset/turn'
import { typeCategory, turnStatus } from '@/utils/options'
import Wangeditor from '@/components/editor/wangeditor'
import VSelect from '@/components/select'
export default {
  inject: ['addOne'],
  components: {
    Wangeditor,
    VSelect
  },
  data() {
    return {
      data: {
        coding: '',
        name: '',
        turn: '1',
        date: '',
        status: 0,
        old_value: '',
        depreciation: '',
        new_value: '',
        type: '',
        sort: '100'
      },
      typeCategory,
      turnStatus,
      formRules: {
        coding: [
          {
            required: true,
            message: '请输入编号',
            trigger: 'blur'
          }
        ],
        name: [
          {
            required: true,
            message: '请输入名称',
            trigger: 'blur'
          }
        ],
        equipment_id: [
          {
            required: true,
            message: '请选择资产',
            trigger: 'change'
          }
        ],
        date: [
          {
            required: true,
            message: '请输入预计日期',
            trigger: 'blur'
          }
        ],
        old_value: [
          {
            required: true,
            message: '请输入原值',
            trigger: 'blur'
          }
        ],
        depreciation: [
          {
            required: true,
            message: '请输入已提折旧',
            trigger: 'blur'
          }
        ],
        new_value: [
          {
            required: true,
            message: '请输入净值',
            trigger: 'blur'
          }
        ],
        sort: [
          {
            required: true,
            message: '请输入排序',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  watch: {},
  created() {},
  methods: {
    save() {
      const thisData = this.data
      const thisForm = this.$refs.form
      this.addOne(API, thisData, thisForm)
    }
  }
}
</script>
